<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/artDialog.js?skin=simple'); ?>"></script>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/plugins/iframeTools.js'); ?>"></script>
<link type="text/css" rel="stylesheet" href="<?php echo $this->basePath('public/css/dbblack/css/product.css'); ?>" />
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/jquery.enlarge.js'); ?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $this->basePath('public/css/dbblack/js/form/style.css'); ?>"/>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/form/form.js'); ?>"></script>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/jquery.form.js'); ?>"></script>
<div class="bread-crumb">
    <ol class="container">
        <li><a href="<?php echo $this->url('shopfront/default'); ?>"><?php echo $this->translate('首页'); ?></a></li>
        <?php if($this->class_menu) { foreach($this->class_menu as $menu_val) {
                ?>
                <li>
                    <a href="<?php echo $this->url('frontgoodslist/default', array('class_id'=>$menu_val['class_id'])); ?>"><?php echo $this->escapeHtml($menu_val['class_name']); ?></a>
                </li>
            <?php } } ?>
        <li><?php echo $this->escapeHtml($this->goods_info->goods_name); ?></li>
    </ol>
</div>
<div class="container">

    <div id="product-intro">
        <div class="sub-1">
            <div id="gallery">
                <a class="turn-left ie6png"></a>
                <div class="show-list">
                    <div style="position: absolute;height:800px;">
                        <?php
                        if($this->goods_images) {
                        $imageCount = count($this->goods_images) - 1;
                        foreach($this->goods_images as $image_k => $image_v) {
                        ?>
                        <a class="small-img <?php if ($this->goods_info->goods_image_id==$image_v['goods_image_id']) echo 'current'; ?>" href="javascript:;"><img src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($image_v['goods_title_image'])); ?>"  source="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($image_v['goods_title_image'])); ?>" width="60"></a>
                        <?php } } ?>
                    </div>
                </div>
            </div>
        </div>
        <div class="sub-2">
            <div id="preview" >
                <div id="imgmini" style="width: 420px;height:420px;"><img class="big-pic" width="420"  src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($this->goods_info->goods_title_image)); ?>" source="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($this->goods_info->goods_title_image)); ?>"></div>
            </div>
        </div>
        <form action="<?php echo $this->url('frontcart/default'); ?>" method="post" name="add_goods_cart" id="add_goods_cart">
        <div class="sub-3">
            <ul class="product-info">
                <li class="product-title"><?php echo $this->escapeHtml($this->goods_info->goods_name); ?> <span style="color: #ed145b;"><?php echo $this->escapeHtml($this->goods_info->goods_extend_name); ?></span></li>
                <li class="product-no"><label><?php echo $this->translate('货号'); ?>：</label><span id="goods_item"><?php echo $this->escapeHtml($this->goods_info->goods_item); ?></span></li>
                <li class="product-price">
                    <span id="goods_price" class="price">
                        <?php if ($this->goods_info->goods_preferential_price <= 0) { ?>
                        <?php echo $this->frontwebsite()->shopPriceExtend($this->goods_info->goods_shop_price); ?>
                        <?php } else { ?>
                            <?php echo $this->frontwebsite()->shopPriceExtend($this->goods_info->goods_preferential_price); $this->goods_info->goods_shop_price =$this->goods_info->goods_preferential_price; ?>
                        <?php } ?>
                    </span>
                    <?php $front_goods_price=intval($this->goods_info->goods_price); if( $front_goods_price>0) { ?>
                    <del style="color: #7B7B7B;font-size: 20px;"><?php echo $this->frontwebsite()->shopPriceExtend($this->goods_info->goods_price); ?></del>
                    <?php } ?>
                    <?php if($this->frontwebsite()->getDbshopGoodsIni('dbshop_goods_QRcode')) { ?>
                        <img style="float: right;" alt="<?php echo $this->translate('手机扫描后，在手机中访问该商品'); ?>" title="<?php echo $this->translate('手机扫描后，在手机中访问该商品'); ?>" width="70px" src="<?php echo  $this->basePath($this->frontwebsite()->createQRcode($this->serverUrl().$this->url('m_goods/default', array('goods_id'=>$this->goods_info->goods_id, 'class_id'=>$this->class_id)), $this->goods_info->goods_id, 'goods')); ?>">
                    <?php } ?>
                </li>

                <?php if(isset($this->click_coupon) and !empty($this->click_coupon)) { ?>
                    <li>
                        <?php echo $this->translate('优惠券'); ?>：
                        <?php foreach ($this->click_coupon as $clickCouponValue) { ?>
                            <div style="min-width: 50px;height: 26px;background:#E5004F;line-height:26px;color: #fff;display: inline-block;text-align: center;">
                                &nbsp;<?=$this->translate('满')?><?=$this->frontwebsite()->currencyPrice($clickCouponValue['shopping_amount'], $this->frontwebsite()->getFrontDefaultCurrency())?><?=$this->translate('减')?><?=$this->frontwebsite()->currencyPrice($clickCouponValue['shopping_discount'], $this->frontwebsite()->getFrontDefaultCurrency())?> &nbsp;&nbsp;
                            </div>
                            <span style="border-right:1px dashed #fff;position: relative;left: -14px;"></span>
                            <div style="width: 10px;height: 10px;border-radius: 50%;background: #fff;display: inline-block;margin-left: -10px;position: relative;">
                            </div>
                        <?php } ?>
                        <span>
                          <a style="text-decoration: underline;" href="<?php echo $this->url('frontgoods/default',array('action'=>'clickCoupon'), array('query'=>array('goods_id'=>$this->goods_info->goods_id)));?>" target="_blank"><?=$this->translate('点击领券')?></a>
                      </span>
                    </li>
                <?php } ?>

                <?php
                $userGroupPriceShowState = $this->frontwebsite()->getDbshopGoodsIni('dbshop_goods_usergroup_price_show');
                if($userGroupPriceShowState == 1 and $this->goods_info->goods_preferential_price <= 0) {
                    ?>
                    <li style="padding-bottom: 0px;<?php if(empty($this->group_price)) { ?>;display: none;<?php } ?>" class="group_price">
                    <span id="group_price_str">
                        <?php
                        if(isset($this->group_price) and !empty($this->group_price)) {
                            foreach($this->group_price as $group_price_value) {
                                ?>
                                <?php echo $this->escapeHtml($group_price_value['group_name']); ?><strong style="color:#ED145B;"><?php echo $this->frontwebsite()->shopPriceExtend($group_price_value['group_price']); ?></strong>&nbsp;
                            <?php } } ?>
                    </span>
                    </li>
                <?php } ?>
                <li style="padding-top: 5px;padding-bottom: 0px;"><?php echo $this->translate('评　分'); ?> <span data-class="icon-stat-5" class="icon-stat icon-stat-<?php if (isset($this->goods_rating->rating)) echo str_replace('.5', 'half', number_format($this->goods_rating->rating,1)); else echo '0'; ?>"></span><span id="goods_comment_num"></span></li>
                <?php if(isset($this->goods_info->goods_integral_num) and $this->goods_info->goods_integral_num > 0) { ?>
                <li style="padding-top: 5px;padding-bottom: 0px;"><strong style="font-size: 14px;"><?php echo $this->translate('可用'); ?>&nbsp;<span id="goods_integral"><?php echo $this->goods_info->goods_integral_num; ?></span>&nbsp;<?php echo $this->translate('消费积分进行购买'); ?></strong></li>
                <?php } ?>
            </ul>
            <?php if((isset($this->brand_info) and !empty($this->brand_info)) or (isset($this->goods_custom) and !empty($this->goods_custom)) or $this->goods_info->goods_weight > 0) {?>
            <fieldset class="line-title">
                <legend align="center" class="txt"><?php echo $this->translate('扩展信息'); ?></legend>
            </fieldset>
            <div>
                <dl class="goods_extend_info">
                    <?php if (isset($this->brand_info) and !empty($this->brand_info)) { ?>
                        <dt><?php echo $this->translate('品 牌'); ?></dt><dd><a href="<?php echo $this->url('frontbrand/default/front-brand-id', array('action'=>'brandGoods', 'brand_id'=>$this->brand_info->brand_id)); ?>"><?php echo $this->escapeHtml($this->brand_info->brand_name); ?></a></dd>
                    <?php } ?>
                    <?php
                    if (isset($this->goods_custom) and !empty($this->goods_custom)) {
                        foreach($this->goods_custom as $gc_value) {
                            ?>
                            <dt><?php echo $this->escapeHtml($gc_value['custom_title']); ?></dt><dd><?php echo $this->escapeHtml($gc_value['custom_content']); ?></dd>
                        <?php } } ?>
                    <?php if($this->goods_info->goods_weight > 0) { ?>
                    <dt><?php echo $this->translate('重　量'); ?></dt><dd><?php echo $this->goods_info->goods_weight; ?><?php echo $this->translate('千克'); ?></dd>
                    <?php } ?>
                </dl>
            </div>
            <?php } ?>

            <?php if(isset($this->relation_goods_array) and !empty($this->relation_goods_array)) { ?>
                <div class="clearfix" style="margin-top: 20px;">
                    <div>
                        <?php foreach($this->relation_goods_array as $relationGoods) { ?>
                            <a title="<?php echo $this->escapeHtml($relationGoods['goods_name']); ?>" href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$relationGoods['goods_id'], 'class_id'=>$relationGoods['one_class_id'])); ?>">
                                <img src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($relationGoods['goods_thumbnail_image'])); ?>" style="border: 1px solid <?php echo ($relationGoods['goods_id'] == $this->goods_info->goods_id ? '#BD0021' : '#D7D7D7'); ?>;width: 40px;margin-right: 5px;">
                            </a>
                        <?php } ?>
                    </div>
                </div>
            <?php } ?>

            <?php if(isset($this->spec_tag_id)) { ?>
                <fieldset class="line-title">
                    <legend align="center" class="txt"><?php echo $this->translate('商品规格'); ?></legend>
                    <input type="hidden" id="selected_spec_tag_id_str" name="selected_spec_tag_id_str" value="" />
                </fieldset>
            <?php } else { ?>
                <fieldset class="line-title">
                </fieldset>
            <?php } ?>
            <div class="spec-info">
                <div class="spec-close"></div>
                <?php
                if(isset($this->goods_spec_group_array) and !empty($this->goods_spec_group_array)) {
                    if(isset($this->spec_tag_id)) {
                        foreach ($this->goods_spec_group_array as $spec_group_value) {
                            ?>
                            <dl class="spec-item clearfix">
                                <dt><strong><?php echo $this->escapeHtml($spec_group_value['tag_group_name']); ?></strong></dt>
                                <dd>
                                    <ul class="spec-values clearfix colorli goods_spec_<?php echo $spec_group_value['tag_group_id']; ?> goods_spec_tag_item" spec_id="<?php echo $spec_group_value['tag_group_id']; ?>">
                                        <?php foreach ($this->spec_tag_id[$spec_group_value['tag_group_id']] as $spec_tag_id) { ?>
                                            <?php if(!empty($this->spec_tag[$spec_tag_id]['tag_str'])) { ?>
                                                <li id="spec_tag_<?php echo $spec_tag_id; ?>" onclick="select_goods_spec(<?php echo $spec_tag_id; ?>, <?php echo $spec_group_value['tag_group_id']; ?>);" style="background-color: <?php echo $this->spec_tag[$spec_tag_id]['tag_str']; ?>;" alt="<?php echo $this->escapeHtml($this->spec_tag[$spec_tag_id]['tag_name']); ?>" title="<?php echo $this->escapeHtml($this->spec_tag[$spec_tag_id]['tag_name']); ?>"><span>&nbsp;&nbsp;</span><i></i></li>
                                            <?php } else { ?>
                                                <li id="spec_tag_<?php echo $spec_tag_id; ?>" onclick="select_goods_spec(<?php echo $spec_tag_id; ?>, <?php echo $spec_group_value['tag_group_id']; ?>);" alt="<?php echo $this->escapeHtml($this->spec_tag[$spec_tag_id]['tag_name']); ?>"><span><?php echo $this->escapeHtml($this->spec_tag[$spec_tag_id]['tag_name']); ?></span><i></i></li>
                                            <?php } ?>
                                        <?php } ?>
                                    </ul>
                                </dd>
                            </dl>
                        <?php } } } ?>

                <dl class="spec-item clearfix">
                    <dt><?php echo $this->translate('购买量'); ?></dt>
                    <dd class="buy-num" id="buy-num-bar">
                        <a href="javascript:;"><i class="icon-minus-16"></i></a><input id="buy_goods_num" name="buy_goods_num" value="<?php echo ($this->goods_info->goods_cart_buy_min_num > 1 ? $this->goods_info->goods_cart_buy_min_num : 1); ?>"  maxlength=5><a href="javascript:;"><i class="icon-plus-16"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="vm"><?php echo $this->translate('库存'); ?>：<b id="goods_stock_show" class="red"><?php echo $this->goods_stock; ?></b></span>
                    </dd>
                </dl>
                <dl id="spec-msg" class="spec-item clearfix" style="display: none;">
                    <dt></dt>
                    <dd ><p class="msg"><i class="icon icon-alert-16"></i><span ><?php echo $this->translate('请选择您要购买的商品规格'); ?></span></p>
                    </dd>
                </dl>
                <dl class="spec-item clearfix">
                    <dd class="product-btns">
                        <input type="hidden" id="goods_id" name="goods_id" value="<?php echo $this->goods_info->goods_id; ?>" />
                        <input type="hidden" id="class_id" name="class_id" value="<?php echo $this->class_id; ?>" />
                        <?php if ($this->goods_info->goods_state == 1) { ?>
                            <a href="javascript:;" id="buy-now" class="btn btn-warning"><i class="icon-basket-32 ie6png"></i><span><?php echo $this->translate('立即购买'); ?></span></a>&nbsp;&nbsp;&nbsp;&nbsp;
                            <a href="javascript:;" id="add-cart" class="btn btn-main"><i class="icon-cart-1-32 ie6png"></i><span><?php echo $this->translate('加入购物车'); ?></span></a>&nbsp;&nbsp;&nbsp;&nbsp;
                            <a href="javascript:;" id="attention" class="btn btn-info"><i class="icon-hart-32 ie6png"></i><span><?php echo $this->translate('收藏'); ?></span></a>
                        <?php } ?>
                        <?php if ($this->goods_info->goods_state == 2) { ?>
                            <b style="color: red;font-size: 18px;"><?php echo $this->translate('该商品已经下架！'); ?></b>
                        <?php } ?>
                    </dd>
                </dl>
                <dl>
                    <dd>
                        <?php echo $this->translate('最近'); ?><span id="ajax_order_count"><?php echo $this->order_count; ?></span><?php echo $this->translate('人已经购买'); ?>
                    </dd>
                    <?php
                    if (isset($GLOBALS['extendModule']['modules']) and !empty($GLOBALS['extendModule']['modules']) and in_array('Dbdistribution', $GLOBALS['extendModule']['modules'])) {
                        $shareGoodsImage = $this->basePath($this->frontwebsite()->shopGoodsImage($this->goods_info->goods_title_image));
                        $shareGoodsImage = strpos($shareGoodsImage, 'http') !== false ? $shareGoodsImage : $this->serverUrl() . $shareGoodsImage;
                        ?>
                        <dd>
                            <a class="bshareDiv" href="http://www.bshare.cn/share"><?php echo $this->translate('分享按钮'); ?></a><script type="text/javascript" charset="utf-8" src="https://static.bshare.cn/b/buttonLite.js#uuid=&amp;style=999&amp;img=http%3A%2F%2Fstatic.bshare.cn%2Fimages%2Fbuttons%2Fbox-shareTo-zh.gif&amp;w=147&amp;h=21"></script>
                            <script type="text/javascript" charset="utf-8">
                                $.get('<?=$this->url('frontgoods/default', array('action'=>'getGoodsShareUrl', 'goods_id'=>$this->goods_info->goods_id, 'class_id'=>$this->class_id))?>','', function(html){
                                    bShare.addEntry({
                                        title: "<?php echo $this->escapeHtml($this->goods_info->goods_name); ?>",
                                        url: html,
                                        summary: "<?php echo $this->escapeHtml($this->goods_info->goods_description); ?>",
                                        pic: "<?php echo $shareGoodsImage; ?>"
                                    });
                                });
                            </script>
                        </dd>
                        <?php
                    } else {
                        $goods_share_info = $this->frontwebsite()->getDbshopGoodsShare();
                        if(!empty($goods_share_info['share_type'])) {
                            echo "<script>var dbshop_baidushare_path='". $this->basePath('/public/js/baiduShare/')."';</script>";
                            if($goods_share_info['share_type'] == '/baidu/window.php' or $goods_share_info['share_type'] == '/baidu/httpswindow.php') {
                                echo $goods_share_info['share_code'];
                            } else {
                                echo '<dd>'.$goods_share_info['share_code'].'</dd>';
                            }
                        }
                    }
                    ?>
                </dl>
            </div>
        </div>
        </form>
    </div>
<script>
    /*商品规格设置*/
    function select_goods_spec(tag_id, tag_group_id) {
        if($('#spec_tag_'+tag_id).attr('class') == 'selected') {
            $('#spec_tag_'+tag_id).attr('class', '');

        } else {
            $('.goods_spec_'+tag_group_id+' li').each(function() {
                $('#'+this.id).css({border: ""});
                $('#'+this.id).attr('class', '');
            });
            $('#spec_tag_'+tag_id).attr('class', 'selected');
        }

        var spec_tag_id_str = [];
        $('.goods_spec_tag_item li').each(function () {
            if($('#'+this.id).attr('class') == 'selected') {
                spec_tag_id_str.push(this.id.replace('spec_tag_', ''));
            }
        });
        $('#selected_spec_tag_id_str').val(spec_tag_id_str);

        get_goods_stock();
    }

    //如果有尺寸和颜色，并且已经选择了，那么获取相关库存
    function get_goods_stock() {
        var selected_spec_tag_id_str = $('#selected_spec_tag_id_str').val();

        if($('#spec-msg').css('display') == 'block') {//对提示信息进行处理
            $("#spec-msg").css("display","none");
            specClose();
        }

        if(selected_spec_tag_id_str != '') {
            $.post("<?php echo $this->url('frontgoods/default',array('action'=>'goodsStock','goods_id'=>$this->goods_info->goods_id)); ?>",{spec_tag_id_str:selected_spec_tag_id_str},
                function(data){
                    if(data != '') {
                        $('#goods_stock_show').html(data.stock);
                        $('#goods_item').html(data.goods_item);
                        <?php if ($this->goods_info->goods_preferential_price <= 0) { ?>
                        $('#goods_price').html(data.price);
                        <?php } ?>
                        <?php if($userGroupPriceShowState == 1 and $this->goods_info->goods_preferential_price <= 0) { ?>
                        if(data.group_price_str == '') {
                            $('.group_price').hide();
                        } else {
                            $('.group_price').show();
                            $('#group_price_str').html(data.group_price_str);
                        }
                        <?php } ?>
                        if(data.goods_integral > 0) $('#goods_integral').html(data.goods_integral);
                    }
                },
                'json');
        }
    }
    //立即购买
    $("#buy-now").on("click",function(){
        <?php if(isset($this->spec_tag_id)) { ?>
        var selected_spec_tag_id_str = $('#selected_spec_tag_id_str').val();
        if(selected_spec_tag_id_str == '') {
            $("#spec-msg").css("display","");
            showMsgBar('alert',"<?php echo $this->translate('请选择您要购买的商品规格！'); ?>");
            return false;
            }
        <?php } ?>
        $.post("<?php echo $this->url('frontcart/default', array('action'=>'addCart')); ?>",$('#add_goods_cart').formSerialize(),
            function(data){
                if(data == 'true') {
                    window.location.href="<?php echo $this->url('frontcart/default'); ?>";
                } else {
                    art.dialog.tips("<p class='warning'>"+data+"</p>");
                    if(data.indexOf("Login") != -1) window.location.href = '<?php echo $this->url('frontuser/default', array('action' => 'login')); ?>';
                }
            });
    });
    //添加到购物车
    $("#add-cart").on("click",function(){
        //对拥有规格的判断
        <?php if(isset($this->spec_tag_id)) { ?>
        var selected_spec_tag_id_str = $('#selected_spec_tag_id_str').val();
        if(selected_spec_tag_id_str == '') {
            $("#spec-msg").css("display","");
            showMsgBar('alert',"<?php echo $this->translate('请选择您要购买的商品规格！'); ?>");
            return false;
        }
        <?php } ?>

        $.post("<?php echo $this->url('frontcart/default', array('action'=>'addCart')); ?>",$('#add_goods_cart').formSerialize(),
            function(data){
                if(data == 'true') {
                    var tmp=$($("#imgmini img").get(0).cloneNode(true));
                    tmp.css({position: 'absolute','z-index':'9998', border:'solid 1px #ccc', background:'#aaf','overflow':'hidden' ,background:'#fff'});
                    var imgView=$("#imgmini").offset();
                    tmp.css(imgView);
                    tmp.appendTo($('body'));
                    var end = $(".shopping").offset();
                    step1 = {top:end.top+160,left:end.left+30,width:100,height:100,opacity:0.8};
                    step2 = {top:end.top,left:end.left+30,width:100,height:100,opacity:0};

                    $(tmp).animate(step1,"slow").animate(step2, "slow",function(){
                        tmp.remove();
                    });

                    updateCart();
                } else {
                    art.dialog.tips("<p class='warning'>"+data+"</p>");
                    if(data.indexOf("Login") != -1) window.location.href = '<?php echo $this->url('frontuser/default', array('action' => 'login')); ?>';
                }
            });

    });

    //关闭信息提示
    $(".spec-close").on("click",function(){
        specClose();
    });
    function specClose()
    {
        $(".spec-info").removeClass("noselected");
    }
    //展示信息
    function showMsgBar(type,text){
        $(".spec-info").addClass("noselected");
        $(".msg").find("span").text(text);
        $(".msg").find("i").attr("class","icon icon-"+type+"-16");
    }
    //商品购买数量设置
    $("#buy-num-bar a:eq(0)").on("click",function(){
        var min_num = <?php echo $this->goods_info->goods_cart_buy_min_num; ?>;
        var num = $("#buy-num-bar input").val();
        if(num>1) num--;
        else num=1;

        if(num <= min_num && min_num != 0) {
            art.dialog.tips("<p class='warning'><?php echo $this->translate('您已经到了购买下限 ！下限为'); ?>"+min_num+"</p>");
            $("#buy-num-bar input").val(min_num);
            $("#buy-num-bar a:eq(0)").addClass('disable');
            return false;
        }

        $("#buy-num-bar input").val(num);
        btnNumStatus(num);
    });
    $("#buy-num-bar a:eq(1)").on("click",function(){
        var max_num = <?php echo $this->goods_info->goods_cart_buy_max_num; ?>;

        var num = $("#buy-num-bar input").val();
        //下面这句是对 有货 或者 显示数字 两种方式的判断
        var max = <?php if($this->goods_info->goods_stock_state_open == 1) { ?>0<?php }else{ ?>parseInt($("#goods_stock_show").text())<?php } ?>;

        if(num<max || max==0) num++;
        else num=max;

        if(num > max_num && max_num != 0) {
            art.dialog.tips("<p class='warning'><?php echo $this->translate('您已经到了购买上限！'); ?></p>");
            $("#buy-num-bar a:eq(1)").addClass('disable');
            return false;
        }

        $("#buy-num-bar input").val(num);
        btnNumStatus(num);
    });
    $("#buy-num-bar input").on("change",function(){
        var value = $(this).val();
        var max = parseInt($("#goods_stock_show").text());
        if((/^\d+$/i).test(value)){
            value = Math.abs(parseInt(value));
            if(value<1) value = 1;
            if(value>max) value = max;
        }else{
            value = 1;
        }
        $(this).val(value);
        btnNumStatus(value);
    })
    function btnNumStatus(value){
        var max = parseInt($("#goods_stock_show").text());
        if(value <= 1){
            $("#buy-num-bar a:eq(0)").addClass('disable');
        }else{
            $("#buy-num-bar a:eq(0)").removeClass('disable');
        }
        if(value >= max){
            $("#buy-num-bar a:eq(1)").addClass('disable');
        }else{
            $("#buy-num-bar a:eq(1)").removeClass('disable');
        }
    }
</script>

    <div class="clearfix">
        <div class="sub-left mt20">
            <?php if (isset($this->related_goods_array) and !empty($this->related_goods_array)) { ?>
            <fieldset class="line-title">
                <legend align="center" class="txt"><?php echo $this->translate('相关商品'); ?></legend>
            </fieldset>
            <ul>
                <?php foreach ($this->related_goods_array as $related_goods_value) { ?>
                <li class="product">
                    <dl>
                        <dt class="img tc"><a href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$related_goods_value['related_goods_id'], 'class_id'=>$related_goods_value['one_class_id'])); ?>" title="<?php echo $this->escapeHtml($related_goods_value['goods_name']); ?>"><img src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($related_goods_value['goods_thumbnail_image'])); ?>" width=200></a></dt>
                        <dd><a href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$related_goods_value['related_goods_id'], 'class_id'=>$related_goods_value['one_class_id'])); ?>"><?php echo $this->escapeHtml($related_goods_value['goods_name']); ?></a></dd>
                        <dd><span class="price"><?php echo $this->translate('售价'); ?>：<b class="red"><?php echo $this->frontwebsite()->shopPriceExtend($related_goods_value['goods_shop_price']); ?></b></span></dd>
                    </dl>
                </li>
                <?php } ?>
            </ul>
            <?php } ?>

            <fieldset class="line-title">
                <legend align="center" class="txt"><?php echo $this->translate('浏览历史'); ?></legend>
            </fieldset>
            <ul id="browser_history">
                <?php if(!defined('FRONT_CACHE_STATE') or FRONT_CACHE_STATE != 'true') { ?>
                    <?php
                    if(isset($_COOKIE['view_goods'])) {
                    $viewGoodsArray = unserialize($_COOKIE['view_goods']);
                    if(is_array($viewGoodsArray) and !empty($viewGoodsArray)) {
                        foreach($viewGoodsArray as $vGoodsValue) {
                    ?>
                    <li class="product">
                        <dl>
                            <dt class="img tc"><a href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$vGoodsValue['goods_id'], 'class_id'=>$vGoodsValue['class_id'])); ?>" title="<?php echo $this->escapeHtml($vGoodsValue['goods_name']); ?>"><img src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($vGoodsValue['image'])); ?>" width=200></a></dt>
                            <dd><a href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$vGoodsValue['goods_id'], 'class_id'=>$vGoodsValue['class_id'])); ?>"><?php echo $this->escapeHtml($vGoodsValue['goods_name']); ?></a></dd>
                        </dl>
                    </li>
                <?php } } } } ?>
            </ul>

        </div>
        <div class="sub-right">
            <div class="goods-detail clearfix">
                <div class="content">

                    <?php if ($this->combination_goods_array) { ?>
                    <div class="tab ">
                        <ul class="tab-head">
                            <li><?php echo $this->translate('组合商品'); ?><i></i></li>
                        </ul>
                        <div class="tab-body" style="min-height: 180px;">
                            <ul class="bundling-list">
                                <li class="sub-1 group-item">
                                    <dl class="product goods-item">
                                        <dt class="img">
                                            <a target="_blank" href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$this->goods_info->goods_id, 'class_id'=>$this->class_id)); ?>"><img src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($this->goods_info->goods_thumbnail_image)); ?>" width="100"></a>
                                        </dt>
                                        <dd class="title"><a target="_blank" href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$this->goods_info->goods_id, 'class_id'=>$this->class_id)); ?>"><?php echo $this->escapeHtml($this->DbshopCommonFun()->dbshopCutStr($this->goods_info->goods_name, 6, true)); ?></a></dd>
                                        <dd class="price"><b class="red price"><?php echo $this->frontwebsite()->shopPriceExtend($this->goods_info->goods_shop_price); ?></b></dd>
                                    </dl>
                                    <?php $combination_goods_count=count($this->combination_goods_array)-1;
                                    foreach ($this->combination_goods_array as $combination_key => $combination_goods_value) { ?>
                                    <dl class="product goods-item">
                                        <s class="icon-add ie6png icon-plus-16"></s>
                                        <dt class="img">
                                            <a href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$combination_goods_value['goods_id'], 'class_id'=>$combination_goods_value['one_class_id'])); ?>" target="_blank"><img src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($combination_goods_value['goods_thumbnail_image'])); ?>" width="100"></a>
                                        </dt>
                                        <dd class="title"><a target="_blank" href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$combination_goods_value['goods_id'], 'class_id'=>$combination_goods_value['one_class_id'])); ?>"><?php echo $this->escapeHtml($this->DbshopCommonFun()->dbshopCutStr($combination_goods_value['goods_name'], 6, false)); ?></a></dd>
                                        <dd class="price"><b class="red price"><?php echo $this->frontwebsite()->shopPriceExtend($combination_goods_value['goods_shop_price']); ?></b></dd>
                                        <dd><input type="checkbox" onclick="count_combination_price();" name="combination_goods_id[]" value="<?php echo $combination_goods_value['goods_id']; ?>" /></dd>
                                        <input type="hidden" name="one_combination_price_<?php echo $combination_goods_value['goods_id']; ?>" id="one_combination_price_<?php echo $combination_goods_value['goods_id']; ?>" value="<?php echo $this->frontwebsite()->shopPrice($combination_goods_value['goods_shop_price']); ?>" />
                                    </dl>
                                    <?php } ?>
                                </li>
                                <li class="sub-2 group-item">
                                    <div class="goods-item" >
                                        <s class="icon-add ie6png icon-equal-16"></s>
                                        <?php $base_goods_price = $this->frontwebsite()->shopPrice($this->goods_info->goods_shop_price); ?>
                                        <input type="hidden" name="base_goods_price" id="base_goods_price" value="<?php echo $base_goods_price; ?>" />
                                        <div style="font-size: large;font-weight: bold;margin-top: 20px;"><?php echo $this->translate('店铺价'); ?>： <?php echo $this->frontwebsite()->shopPriceSymbol().'<span id="show_combination_count_price">'.$base_goods_price.'</span>'.$this->frontwebsite()->shopPriceUnit(); ?></div>
                                        <div class="mt10">
                                            <?php if ($this->goods_info->goods_state == 1) { ?>
                                            <a href="javascript:;" onclick="combination_goods_add_cart();" class="btn btn-main"><?php echo $this->translate('组合购买'); ?></a>
                                            <?php } ?>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <?php } ?>

                    <div class="tab clearfix">
                        <ul class="tab-head">
                            <li><?php echo $this->translate('商品详情'); ?><i></i></li>
                            <li id="goodsComment"><?php echo $this->translate('商品评价'); ?><i></i></li>
                            <li><?php echo $this->translate('商品咨询'); ?><i></i></li>
                            <li><?php echo $this->translate('售后服务'); ?><i></i></li>
                            <li><?php echo $this->translate('如何购买'); ?><i></i></li>
                            <li><?php echo $this->translate('品质保证'); ?><i></i></li>
                        </ul>
                        <div class="tab-body" style="min-height: 200px;">
                            <div class=" clearfix">
                                <?php if(isset($this->goods_attribute) and !empty($this->goods_attribute)) { ?>
                                <div class="">
                                    <ul class="attr-list">
                                        <?php foreach($this->goods_attribute as $b_key => $b_val) { ?>
                                        <li><?php echo $b_val; ?></li>
                                        <?php } ?>
                                    </ul>
                                </div>
                                <?php } ?>
                                <div class="description edit_table_css clearfix" id="goodsDesc">
                                    <?php echo $this->frontwebsite()->shopGoogsBody($this->goods_info->goods_body); ?>
                                </div>
                            </div>

                            <div class="comment-list">
                                <div class="comment tab" id="list_goodscomment">

                                </div>
                            </div>

                            <div class="consult clearfix" >
                                <form method="post" name="ask_form" id="ask_form">
                                    <input type="hidden" name="goods_id" value="<?php echo $this->goods_info->goods_id; ?>" />
                                    <div>
                                        <div class="txt-panel mb5">
                                            <textarea name="goods_ask_content" id="goods_ask_content"  class="p5"></textarea>
                                        </div>
                                        <div class="consult-footer">
                                            <?php if ($this->frontwebsite()->websiteCaptchaState('goods_ask_captcha') == 'true') { ?>
                                            <span class="fl"><input type="text" class="input" id="captcha_code" name="captcha_code" pattern="\w{5}" maxlength="5" alt="<?php echo $this->translate('验证码不正确'); ?>" placeholder="<?php echo $this->translate('验证码'); ?>" style="width: 80px;" >&nbsp;<span id="ask_captcha_id"></span></span>
                                            <?php } ?>
                                            <span class="fr">
                                                <input type="button" id="consult" value="<?php echo $this->translate('咨询'); ?>" class="btn btn-main"> <input type="reset" value="<?php echo $this->translate('取消'); ?>" class="btn btn-gray">
                                            </span>
                                        </div>
                                    </div>
                                </form>
                                <div id="goods-consult" class="js-template">

                                </div>
                            </div>
                            <!--E 商品咨询-->

                            <div class="clearfix">
                                <div class="mb20">
                                    <?php echo $this->frontwebsite()->getSystemContent('buy_service'); ?>
                                </div>
                            </div>
                            <div class="clearfix">
                                <div class="mb20">
                                    <?php echo $this->frontwebsite()->getSystemContent('buy'); ?>
                                </div>
                            </div>
                            <div class="clearfix">
                                <div class="mb20">
                                    <?php echo nl2br($this->escapeHtml($this->frontwebsite()->getSystemContent('goods_quality'))); ?>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<script type="text/javascript">
    $("#imgmini").enlarge({
        // 鼠标遮罩层样式
        shadecolor: "#FFF",
        shadeborder: "#FF8000",
        shadeopacity: 0.5,
        cursor: "move",

        // 大图外层样式
        layerwidth: 420,
        layerheight: 420,
        layerborder: "#FFF",
        fade: true});

    $("#gallery  .small-img").each(function(i){
        //if(i==0)$(this).addClass("current");
        $(this).on("mouseenter",function(){
            $(this).parent().find("a").removeClass("current");
            $(this).addClass("current");
            $("#imgmini img").attr("src",$(this).find("img").attr("src"));
            $("#imgmini img").attr("source",$(this).find("img").attr("source"));
        })
    });
    //收藏
    $("#attention").on("click",function(){
        $.post("<?php echo $this->url('frontuser/default',array('action'=>'addFavorites')); ?>",{goods_id:<?php echo $this->goods_info->goods_id; ?>,class_id:<?php echo $this->class_id; ?>},function(data){
            if(data=='true') {
                art.dialog.tips("<p class='success'><?php echo $this->translate('该商品成功加入收藏！'); ?></p>");
            } else {
                if(data == 'login_false') {
                    art.dialog.tips("<p class='warning'><?php echo $this->translate('您还没有登录，无法收藏商品！'); ?></p>");
                } else if (data == 'goods_exists') {
                    art.dialog.tips("<p class='success'><?php echo $this->translate('您已经收藏过该商品！'); ?></p>");
                } else {
                    art.dialog.tips("<p class='warning'><?php echo $this->translate('商品收藏不成功！'); ?></p>");
                }
            }
        })
    })

    <?php if ($this->combination_goods_array) { ?>
    //组合商品js
    /*------计算组合商品价格-------------*/
    function count_combination_price() {
        var combination_price = $('#base_goods_price').val();
        $("input[name='combination_goods_id[]']").each(function() {
            if (this.checked == true) {
                combination_price = accAdd(combination_price, $('#one_combination_price_'+this.value).val());
            }
        });
        $('#show_combination_count_price').html(combination_price);
    }
    /*------提交组合商品-------------*/
    function combination_goods_add_cart() {
        $.post("<?php echo $this->url('frontcart/default', array('action'=>'getAddCartInfo')); ?>",{goods_id:<?php echo $this->goods_info->goods_id; ?>,class_id:<?php echo $this->class_id; ?>},
            function (data) {
                if(data != '') {
                    $.post("<?php echo $this->url('frontcart/default', array('action'=>'addCart')); ?>",{goods_id:data.goods_id, class_id:data.class_id, buy_goods_num:1, select_color_value:data.select_color_value, select_size_value:data.select_size_value, selected_spec_tag_id_str:data.selected_spec_tag_id_str},function() { updateCart(); });
                }
            },'json');
        $("input[name='combination_goods_id[]']").each(function() {
            if (this.checked == true) {
                $.post("<?php echo $this->url('frontcart/default', array('action'=>'getAddCartInfo')); ?>",{goods_id:this.value},
                    function (data) {
                        if(data != '') {
                            $.post("<?php echo $this->url('frontcart/default', array('action'=>'addCart')); ?>",{goods_id:data.goods_id, class_id:data.class_id, buy_goods_num:1, select_color_value:data.select_color_value, select_size_value:data.select_size_value, selected_spec_tag_id_str:data.selected_spec_tag_id_str});
                        }
                    },'json');
            }
        });

        setTimeout(function(){
            art.dialog.tips("<p class='success'><?php echo $this->translate('组合商品添加购物车成功！'); ?></p>");
        }, 2000);

    }
    <?php } ?>


    $("#consult").on("click",function(){

        var content = $("#goods_ask_content").val();
        var verifyCode = $("#captcha_code").val();
        if(content=='')art.dialog.alert("<?php echo $this->translate('内容不能为空！'); ?>");
        else if(verifyCode=='')art.dialog.alert("<?php echo $this->translate('验证码不能为空！'); ?>");
        else{
            $.post("<?php echo $this->url('frontgoods/default', array('action'=>'addAsk')); ?>",$('#ask_form').formSerialize(),
                function(data){
                    if(data == 'true') {
                        $('#goods_ask_content').val('');
                        <?php if ($this->frontwebsite()->websiteCaptchaState('goods_ask_captcha') == 'true') { ?>
                        $('#captcha_code').val('');
                        captchaAdd();
                        <?php } ?>
                        art.dialog.tips("<p class='success'><?php echo $this->translate('发布成功！'); ?></p>");
                    } else {
                        art.dialog.alert("<p class='fail'>"+data+"</p>");
                    }
                });
        }

        return false;
    })
    <?php if ($this->frontwebsite()->websiteCaptchaState('goods_ask_captcha') == 'true') { ?>
    $("input[name='captcha_code']").on("change",function(event){
        if(autoValidate.validate(event)){
            $.post("<?php echo $this->url('shopfront/default/captcha-check',array('action'=>'captcha','captcha_check'=>1)); ?>",{captcha_code:$(this).val()},function(data){
                if(data == 'false') {
                    autoValidate.showMsg({id:document.getElementById('captcha_code'),error:true,msg:'<?php echo $this->translate('验证码错误！'); ?>'});
                }
            });
        }
    });
    //验证码添加
    function captchaAdd() {
        $.get("<?php echo $this->url('shopfront/default',array('action'=>'captcha')); ?>",{},
            function(data){
                $("#ask_captcha_id").html('<img src="<?php echo $this->basePath('/'); ?>'+data.captcha_file+'" border="0" >&nbsp;&nbsp;<a href="javascript:;" onclick="captchaAdd()"><?php echo $this->translate('更换验证码'); ?></a>');
            },'json');
    }
    captchaAdd();
    <?php } ?>


    <?php if(defined('FRONT_CACHE_STATE') and FRONT_CACHE_STATE == 'true') { ?>
    $.get('<?php echo $this->url('frontgoods/default',array('action'=>'browserhistory'),array('query'=>array('goods_id'=>$this->goods_info->goods_id, 'class_id'=>$this->class_id))); ?>','', function(html){
        $("#browser_history").html(html);
    });
    $.get('<?php echo $this->url('frontgoods/default',array('action'=>'ajaxgoodsStock'),array('query'=>array('goods_id'=>$this->goods_info->goods_id, 'class_id'=>$this->class_id))); ?>','', function(data){
        $("#goods_stock_show").html(data.goods_stock);
        $("#ajax_order_count").html(data.order_count);
    },'json');
    <?php } ?>

    //商品咨询列表获取
    function ask_ajax_list(list_url) {
        $.get(list_url,'', function(html){
            $("#goods-consult").html(html);
        });
    }
    ask_ajax_list('<?php echo $this->url('frontgoods/default',array('action'=>'goodsAsk'),array('query'=>array('goods_id'=>$this->goods_info->goods_id, 'class_id'=>$this->class_id))); ?>');
    //商品评价列表
    function comment_ajax_list(list_url) {
        $.get(list_url,'', function(html){
            $("#list_goodscomment").html(html);
        });
    }
    comment_ajax_list('<?php echo $this->url('frontgoods/default',array('action'=>'listComment'),array('query'=>array('goods_id'=>$this->goods_info->goods_id, 'class_id'=>$this->class_id))); ?>');

    $("#goodsDesc img").each(function(i){
        if(this.width>980) {
            this.width = 980;
        }
    });
</script>
